package com.atguigu.lease.admin.controller;

import com.atguigu.lease.admin.service.LeaseTermService;
import com.atguigu.lease.pojo.LeaseTerm;
import com.atguigu.lease.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/admin/term")
@RestController
public class LeaseTermController {
    @Autowired
    private LeaseTermService leaseTermService;

    @GetMapping("/list")
    public Result<List<LeaseTerm>> list() {
        List<LeaseTerm> list = leaseTermService.list();
        return Result.success(list);
    }

    @PostMapping("/saveOrUpdate")
    public Result saveOrUpdate(@RequestBody LeaseTerm leaseTerm) {
        leaseTermService.saveOrUpdate(leaseTerm);
        return Result.success(null);
    }

    @DeleteMapping("/deleteById")
    public Result deleteById(@RequestParam(value = "id") Long id) {
        leaseTermService.removeById(id);
        return Result.success(null);
    }
}
